package cn.ixiaoxin.deepchat.controller;

import cn.ixiaoxin.deepchat.DTO.ChatHistoryDTO;
import cn.ixiaoxin.deepchat.DTO.MessageDTO;
import cn.ixiaoxin.deepchat.entity.Message;
import cn.ixiaoxin.deepchat.service.MessageService;
import cn.ixiaoxin.deepchat.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    // 发送消息
    @PostMapping("/send")
    public Result<?> sendMessage(@RequestBody MessageDTO messageDTO) {
        return messageService.sendMessage(messageDTO);
    }

    // 获取聊天历史
    @PostMapping("/history")
    public Result<?> getChatHistory(@RequestBody ChatHistoryDTO chatHistoryDTO) {
        return messageService.getChatHistory(chatHistoryDTO);
    }
}
